using System;
using Org.BouncyCastle.Math;
namespace ch.ethz.ssh2.packets
{
	
	/// <summary> PacketKexDhGexReply.
	/// 
	/// </summary>
	/// <author>  Christian Plattner
	/// </author>
	/// <version>  2.50, 03/15/10
	/// </version>
	public class PacketKexDhGexReply
	{
		virtual public BigInteger F
		{
			get
			{
				return f;
			}
			
		}
		virtual public byte[] HostKey
		{
			get
			{
				return hostKey;
			}
			
		}
		virtual public byte[] Signature
		{
			get
			{
				return signature;
			}
			
		}
		internal byte[] payload;
		
		internal byte[] hostKey;
		internal BigInteger f;
		internal byte[] signature;
		
		public PacketKexDhGexReply(byte[] payload, int off, int len)
		{
			this.payload = new byte[len];
			Array.Copy(payload, off, this.payload, 0, len);
			
			TypesReader tr = new TypesReader(payload, off, len);
			
			int packet_type = tr.readByte();
			
			if (packet_type != Packets.SSH_MSG_KEX_DH_GEX_REPLY)
				throw new System.IO.IOException("This is not a SSH_MSG_KEX_DH_GEX_REPLY! (" + packet_type + ")");
			
			hostKey = tr.readByteString();
			f = tr.readMPINT();
			signature = tr.readByteString();
			
			if (tr.remain() != 0)
				throw new System.IO.IOException("PADDING IN SSH_MSG_KEX_DH_GEX_REPLY!");
		}
	}
}